package com.tz.fdz_jiance.utils;

import lombok.extern.slf4j.Slf4j;
import org.json.JSONObject;

import javax.servlet.ServletResponse;
import java.io.PrintWriter;
import java.util.HashMap;

@Slf4j
public class RequestUtils {

    public static void out(ServletResponse response, HashMap object){
        PrintWriter out = null;
        try {
            response.setContentType("application/json;charset=UTF-8");
            response.setCharacterEncoding("UTF-8");
            out = response.getWriter();
            JSONObject jsonObj = new JSONObject(object);
            out.println(jsonObj.toString());
        } catch (Exception e) {
            log.error("输出JSON报错!"+e);
        }finally{
            if(null != out){
                out.flush();
                out.close();
            }
        }
    }
}
